Enough background. Onto some Perl hacking. All you
really need to get your scripts working is good old Notepad (or
another text editor) and some Web space with a CGI bin. You've
got almost certainly Notepad already, and you'll find a list of
completely free hosts in the Resources
section.
But it's useful to try out your Perl scripts on your own computer
before you upload them. It'll save you the connection charges
while you figure things out, and makes ironing out bugs much easier.
For this you'll need a Web server and a Perl interpreter.
|
Check you've got a green Xitami
icon at the bottom right of your screen. If
it's red, the server isn't running.
|
|
|
Running a Web server sounds like a big deal, and possibly expensive.
It isn't. Microsoft used to make a program called Personal Web
Server (PWS) that ran on Windows 95 and 98, but unfortunately
it no longer supported in Windows Millennium and is tricky to
set up to run Perl. But there are other, better servers around.
We've settled on Xitami, because it works straight out the box,
is easy to use and (is this beginning to sound familiar?) completely
free.
We've bundled Xitami together with ActivePerl - the version of
Perl that runs under Windows - into a single set up program on
the CD. Fire it up before going further. If you're already using
PWS, the installer will give you the choice of using it instead
of Xitami. Please read the Using Personal Web Server box before
deciding which to use.
Testing Perl
Once the setup is finished and your computer has restarted, it's
time to try out your first script. When you're running a Web server
on your own computer, your machine becomes the 'localhost'. To
view Web pages from the server, open your browser and type http://127.0.0.1
into the address bar. This number is a special IP address that
always points to the local server. Most computers will also understand
the easier to remember localhost
address if you type it into your browser.
|
If you get a 'Web page unavailable
offline' message when you try to access your
server, don't panic.Click 'Connect' - your modem
won't dial.
|
|
|
Try it. You'll get a screen saying 'Welcome to Xitami' with lots
of information about the program and links to it's documentation.
Now make sure Perl is working properly. Type http://127.0.0.1/cgi-bin/test-perl.pl
into the address bar. If all's well, you'll get a message saying
'Hello from Perl' and giving you some information about the server
environment.
If you run into errors at this point, check Xitami is actually
running. If it still doesn't work, the chances are the set up
didn't go smoothly. Make sure you're not running another Web server.
If not, use Add/Remove Programs in your Control Panel to uninstall
Xitami and ActivePerl and run the installer again, making sure
you restart your computer when prompted.
NEXT: Setting up a chat room